//
//  whiteViewController.m
//  10702
//
//  Created by student on 16/2/22.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "whiteViewController.h"
#import "OneViewController.h"
#import "TwoViewController.h"
#import "ThreeViewController.h"
@interface whiteViewController ()
@property (nonatomic,strong) OneViewController *oc;
@property (nonatomic,strong) TwoViewController *tc;
@property (nonatomic,strong) ThreeViewController *thc;
@property (nonatomic,assign) BOOL three;
@property (nonatomic,assign) BOOL one;
@end

@implementation whiteViewController
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        self.three=NO;
        self.one=YES;
    }
    return self;
}

-(OneViewController *)oc
{
    if(_oc==nil)
    {
        _oc=[[OneViewController alloc]init];
    }
    return _oc;
}
-(TwoViewController *)tc
{
    if(_tc==nil)
    {
        _tc=[[TwoViewController alloc]init];
    }
    return _tc;
}

-(ThreeViewController *)thc
{
    if(_thc==nil)
    {
        _thc=[[ThreeViewController alloc]init];
    }
    return _thc;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self first:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)first:(id)sender
{
    [UIView beginAnimations:@"ViewFlip" context:nil];
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [self.view insertSubview:self.oc.view atIndex:0];
        [self.tc.view removeFromSuperview];
        [self.thc.view removeFromSuperview];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
    [UIView commitAnimations];
    if(self.three==YES)
    {
        self.three=NO;
        self.one=YES;
    }
    else
    {
        self.one=YES;
    }
}
- (IBAction)second:(id)sender
{
    
    [UIView beginAnimations:@"ViewFlip" context:nil];
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    if(self.one==YES)
    {
        [self.view insertSubview:self.tc.view atIndex:0];
        [self.oc.view removeFromSuperview];
        [self.thc.view removeFromSuperview];
        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
//        self.one=!self.one;
    }
    else if(self.three==YES)
    {
        [self.view insertSubview:self.tc.view atIndex:0];
        [self.thc.view removeFromSuperview];
        [self.oc.view removeFromSuperview];

        [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
//         self.three=!self.three;
    }
    [UIView commitAnimations];
}
- (IBAction)third:(id)sender
{
    [UIView beginAnimations:@"ViewFlip" context:nil];
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [self.view insertSubview:self.thc.view atIndex:0];
        [self.oc.view removeFromSuperview];
        [self.tc.view removeFromSuperview];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
    [UIView commitAnimations];
    if(self.one==YES)
    {
        self.one=NO;
        self.three=YES;
    }
   else
   {
       self.three=YES;
   }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
